<!DOCTYPE html>
<html>

<head>
    <title>APP更新操作</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link href="${ctxPath}/assets/expand/images/favicon.ico" rel="icon">
    <link rel="stylesheet" href="${ctxPath}/assets/common/libs/layui/css/layui.css?v=${constants.getReleaseVersion()}"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/css/login.css?v=${constants.getReleaseVersion()}" media="all">
    <style>
        body {
            background-image: url("${ctxPath}/assets/common/images/bg_login2.png");
            background-position: center 110px;
            background-repeat: no-repeat;
            background-size: 100%;
            background-color: #f0f2f5;
        }

        .login-header {
            color: rgba(0, 0, 0, .85) !important;
        }

        .login-header i{
            font-size: 40px;
            color: #666;
        }

        .login-footer {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a:hover {
            color: rgba(0, 0, 0, 0.4) !important;
        }
    </style>
    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>

<body>
<div class="login-wrapper">

    <div class="login-header">
        <img src="${ctxPath}/assets/expand/images/logo.png" alt="">
<!--        <i class="layui-icon layui-icon-template-1"></i>-->
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-upload-drag"></i>&nbsp;&nbsp;APP升级
            </div>
            <div class="layui-card-body layui-form layui-form-pane" lay-filter="loginForm">
                <div class="layui-form-item">
                    <label class="layui-form-label">安卓:V</label>
                    <div class="layui-input-block">
                        <input name="version" id="version" placeholder="安卓版本号" value="${version}" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">安卓信息</label>
                    <div class="layui-input-block">
                        <input name="msg" id="msg" placeholder="更新信息" value="${msg}" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">IOS:V</label>
                    <div class="layui-input-block">
                        <input name="iversion" id="iversion" placeholder="IOS版本号" value="${iversion}" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">IOS信息</label>
                    <div class="layui-input-block">
                        <input name="imsg" id="imsg" placeholder="IOS信息" value="${imsg}" type="text" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">密码</label>
                    <div class="layui-input-block">
                        <input name="pwd" id="pwd" placeholder="密码"  value="" type="password" lay-verify="required" class="layui-input">
                    </div>
                </div>
                <div class="layui-form-item layui-row">
                    <button class="layui-btn layui-btn-fluid" id="submit">更新版本信息</button>
                    <button type="button" class="layui-btn layui-icon layui-icon-file" id="apk">上传APK</button>
                </div>
            </div>
        </div>
    </div>
</div>
<style>
    .layui-btn-fluid{
        width: 150px;
    }
</style>
@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "${ctxPath}",
        version: '${constants.getReleaseVersion()}',
        cdn: '${constants.getCdn()}'
    };
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/libs/layui/layui.js?v=${constants.getReleaseVersion()}"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js?v=${constants.getReleaseVersion()}"></script>

<script>
    layui.use(['layer', 'form', 'index', 'ax', 'upload'], function () {
        var $ = layui.jquery;
        var $ax = layui.ax;
        var layer = layui.layer;
        var form = layui.form;
        var upload = layui.upload;
        //普通图片上传
        upload.render({
            elem: '#apk',
            url: Feng.ctxPath + '/upload',
            accept: 'file',
            exts: 'apk',
            before: function(){
                layer.load();
            },
            data:{pwd: function(){return $("#pwd").val()}}
            ,done: function(res){
                if(res.success){
                    Feng.success("上传成功！");
                }else{
                    console.log(res)
                    Feng.error("上传失败！" + res.message)
                }
                layer.closeAll('loading'); //关闭loading
            }
            ,error: function(data){
                console.log(data);
                Feng.error("上传失败！" + data.responseJSON.message)
                layer.closeAll('loading'); //关闭loading
            }
        });
        //登录操作
        $('#submit').click(function () {
            var ajax = new $ax(Feng.ctxPath + "/updateMsg", function (data) {
                Feng.success("更新成功!");
                window.location.reload();
            }, function (data) {
                layer.msg("更新失败！" + data.responseJSON.message, {icon: 5, anim: 6});
            });
            var pwd = $("#pwd").val();
            var version = $("#version").val();
            var msg = $("#msg").val();
            var iversion = $("#iversion").val();
            var imsg = $("#imsg").val();
            if(!version){
                layer.msg("请填写安卓版本号", {icon: 5, anim: 6});
                return;
            }
            if(!msg){
                layer.msg("请填写安卓更新信息", {icon: 5, anim: 6});
                return;
            }
            if(!iversion){
                layer.msg("请填写IOS版本号", {icon: 5, anim: 6});
                return;
            }
            if(!imsg){
                layer.msg("请填写IOS更新信息", {icon: 5, anim: 6});
                return;
            }
            if(!pwd){
                layer.msg("请输入密码", {icon: 5, anim: 6});
                return;
            }
            ajax.set("pwd", pwd);
            ajax.set("version", version);
            ajax.set("msg", msg);
            ajax.set("iversion", iversion);
            ajax.set("imsg", imsg);
            ajax.start();
        });
    });
</script>


</body>
</html>
